﻿namespace Syngine.Components.Animations
{
	public class AnimationPlayer : IPlayable
	{
		public Animation Animation { get; private set; }

		public PlayableState State
		{
			get
			{
				return Animation.State;
			}
		}

		public void Play()
		{
			Animation.Play();
		}

		public void Play(Animation animation)
		{
			if (Animation != null && Animation != animation)
			{
				Animation.Stop();
			}

			animation.Play();
			Animation = animation;
		}

		public void Stop()
		{
			Animation.Stop();
		}

		public void Pause()
		{
			Animation.Pause();
		}

		public void Update(UpdateContext context)
		{
			if (Animation != null)
			{
				Animation.Update(context);
			}
		}

		public void Draw(DrawContext context)
		{
			if (Animation != null)
			{
				Animation.Draw(context);
			}
		}
	}
}
